<?php
namespace models;

use Doctrine\Common\Collections\ArrayCollection;

/**
 * @Entity
 */
class Teknisi extends Akun{

	/**
	 * @Column(type="string", nullable=true)
	 */
	protected $keahlian;

	/**
	 * @OneToMany(targetEntity="Kunjungan", mappedBy="teknisi")
	 */
	protected $kunjungan;

    public function __construct($username=null,$password=null,$email=null, $nama=null){
		parent::__construct($username, $password, $email, $nama);
		$this->kunjungan = new ArrayCollection();
	}

	public function set_keahlian($keahlian){
		$this->keahlian = $keahlian;
		$this->updated = new \DateTime("now");
	}

	public function get_keahlian(){
		return $this->keahlian;
	}
	
	public function add_kunjungan(Kunjungan $kunjungan){
		$this->kunjungan[] = $kunjungan; 
		//$this->updated = new \DateTime("now");
	}

	public function get_kunjungan(){
		return $this->kunjungan;
	}

	static public function get_dropdown_options(){

		$CI =& get_instance();

		$teknisi = $CI->doctrine->em
			->createQuery('SELECT t FROM models\Teknisi t')
			->getResult();

		$option_teknisi = array();
		foreach($teknisi as $t){
			$option_teknisi[$t->get_id()] = $t->get_username().' - '.$t->get_nama();
		};

		return $option_teknisi;
	}
}
